#region imports

using System.ComponentModel;
using System;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.Collections.Generic;
using MimeCloud.AssetManagement.Business.Interface;

#endregion

namespace MimeCloud.AssetManagement.Business
{
    [Serializable]
    public class AssociatedContent : IAssociatedContent
    {
        #region properties

        [XmlElement ( "id" )]
        public int ID { get; set; }

        [XmlElement ( "assetid" )]
        public int AssetID { get; set; }

        [XmlIgnore]
        public int AssociatedContentTypeID { get; set; }

        [XmlIgnore]
        public int StatusID { get; set; }

        [XmlElement ( "creationdate" )]
        public DateTime CreationDate { get; set; }

        [XmlElement ( "updateddate" )]
        public DateTime UpdatedDate { get; set; }

        [XmlElement ( "contentvalue" )]
        public string ContentValue { get; set; }

        [XmlElement ( "associatedcontenttype" )]
        public IAssociatedContentType AssociatedContentType { get; set; }

        [XmlElement ( "status" )]
        public IStatus Status { get; set; }

        [XmlElement ( "asset" )]
        public IAsset Asset { get; set; }

        #endregion

        #region constructors

        public AssociatedContent ( ) { }

        public AssociatedContent ( int id , int assetId , int associatedContentTypeId , int statusId , DateTime created , DateTime updated , string value )
        {
            this.ID = id;
            this.AssetID = assetId;
            this.AssociatedContentTypeID = associatedContentTypeId;
            this.StatusID = statusId;
            this.CreationDate = created;
            this.UpdatedDate = updated;
            this.ContentValue = value;
        }

        public AssociatedContent ( IAssociatedContent entity )
        {
            this.ID = entity.ID;
            this.AssetID = entity.AssetID;
            this.AssociatedContentTypeID = entity.AssociatedContentTypeID;
            this.StatusID = entity.StatusID;
            this.CreationDate = entity.CreationDate;
            this.UpdatedDate = entity.UpdatedDate;
            this.ContentValue = entity.ContentValue;
        }

        #endregion

        #region overridden methods

        public override string ToString ( )
        {
            StringBuilder str = new StringBuilder ( );

            str.Append ( "-> ID: " + this.ID.ToString ( ) );
            str.Append ( "-> AssetID: " + this.AssetID.ToString ( ) );
            str.Append ( "-> AssociatedContentTypeID: " + this.AssociatedContentTypeID.ToString ( ) );
            str.Append ( "-> StatusID: " + this.StatusID.ToString ( ) );
            if ( this.CreationDate != null ) str.Append ( "-> CreatedDate: " + this.CreationDate.ToShortDateString ( ) );
            if ( this.UpdatedDate != null ) str.Append ( "-> UpdatedDate: " + this.UpdatedDate.ToShortDateString ( ) );
            str.Append ( "-> Value: " + this.ContentValue );

            return str.ToString ( );
        }

        #endregion
    }
}
